export default {
  methods: {
    handleSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.submit()
        }
      })
    },
    async submit() {
      const json = await this.$api.login.login(this.params);
      if (!json) {
        return;
      }
      this.$cookie.setCookie('token', json.user_agent_id)
      this.$store.dispatch('TOGGLE_USER_ID', json.user_agent_id)
      this.$store.dispatch('TOGGLE_USER_ISLOGIN', !!json.user_agent_id)
      this.$store.dispatch('TOGGLE_LEVEL', json.user_agent_level)
      this.$router.replace({ name: 'AgentReport' })
    }
  },
}